
package com.insigma.business.qrcode.soldier.service.impl;


import com.insigma.business.qrcode.common.service.SequenceGenerator;
import com.insigma.business.qrcode.common.util.AdminAreaCodeUtils;
import com.insigma.business.qrcode.soldier.dao.SoldierDifficultyRegistrationInfoDao;
import com.insigma.business.qrcode.soldier.dto.SequenceNameConstant;
import com.insigma.business.qrcode.soldier.entity.DataStatsCDO;
import com.insigma.business.qrcode.soldier.entity.SoldierDifficultyFullInfoDO;
import com.insigma.business.qrcode.soldier.entity.SoldierDifficultyRegistrationInfoDO;
import com.insigma.business.qrcode.soldier.request.SoldierDifficultyRegistrationInfoBSearcher;
import com.insigma.business.qrcode.soldier.service.SoldierDifficultyRegistrationInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("soldierDifficultyRegistrationInfoService")
public class SoldierDifficultyRegistrationInfoServiceImpl implements SoldierDifficultyRegistrationInfoService {

    @Autowired(required = false)
    private SoldierDifficultyRegistrationInfoDao soldierDifficultyRegistrationInfoDao;
    @Autowired(required = false)
    private SequenceGenerator sequenceGenerator;

    
    @Override
    public List<SoldierDifficultyRegistrationInfoDO> search(final SoldierDifficultyRegistrationInfoBSearcher soldierDifficultyRegistrationInfoBSearcher) {
        return soldierDifficultyRegistrationInfoDao.search(soldierDifficultyRegistrationInfoBSearcher);
    }

    @Override
    public List<SoldierDifficultyFullInfoDO> searchFull(SoldierDifficultyRegistrationInfoBSearcher innerSearcher) {
        return soldierDifficultyRegistrationInfoDao.searchFull(innerSearcher);
    }

    
    @Override
    public SoldierDifficultyRegistrationInfoDO get(final String id){
        return soldierDifficultyRegistrationInfoDao.get(id);
    }

    
    @Override
    public Integer insert(final SoldierDifficultyRegistrationInfoDO soldierDifficultyRegistrationInfoDO){
        soldierDifficultyRegistrationInfoDO.setId(sequenceGenerator.genKey(SequenceNameConstant.SOLDIER_DIFFICULTY_REGISTRATION_INFO_ID));
        return soldierDifficultyRegistrationInfoDao.insert(soldierDifficultyRegistrationInfoDO);
    }

    
    @Override
    public Integer update(final SoldierDifficultyRegistrationInfoDO soldierDifficultyRegistrationInfoDO){
        return soldierDifficultyRegistrationInfoDao.update(soldierDifficultyRegistrationInfoDO);
    }

    
    @Override
    public Integer delete(final String id, final String modifierType, final String modifierId){
        return soldierDifficultyRegistrationInfoDao.delete(id,modifierType,modifierId);
    }

    @Override
    public List<SoldierDifficultyRegistrationInfoDO> getByIdCardNo(String idCardNo) {
        return soldierDifficultyRegistrationInfoDao.getByIdCardNo(idCardNo);
    }

    @Override
    public Integer countBySituation(String adminAreaCode, String situation) {
        return soldierDifficultyRegistrationInfoDao.countBySituation(AdminAreaCodeUtils.getCutdAreaCode(adminAreaCode), situation);
    }

    @Override
    public Integer countByAreaAndSource(String adminAreaCode, String source) {
        return soldierDifficultyRegistrationInfoDao.countByAreaAndSource(AdminAreaCodeUtils.getCutdAreaCode(adminAreaCode), source);
    }

    @Override
    public List<DataStatsCDO> groupDifficultySoldierMap(String adminAreaCode) {
        int level = AdminAreaCodeUtils.getLevel(adminAreaCode);
        String areaLike = AdminAreaCodeUtils.getCutdAreaCode(adminAreaCode) + "%";
        int nextLevel = level + 1;
        int levelLength = AdminAreaCodeUtils.getLevelLength(nextLevel);
        return soldierDifficultyRegistrationInfoDao.groupDifficultySoldierMap(areaLike, nextLevel, levelLength);
    }

}
